package io.noties.markwon.plugin.syntax


import io.noties.prism4j.Prism4j

import io.noties.markwon.base.AbstractMarkwonPlugin
import io.noties.markwon.base.MarkwonConfiguration
import io.noties.markwon.theme.MarkwonCategoryTheme


class SyntaxHighlightPlugin(
    private val prism4j: Prism4j,
    private val theme: Prism4jTheme,
    private val fallbackLanguage: String?
) : AbstractMarkwonPlugin() {
    /*@Override
    public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
        builder
                .codeTextColor(theme.textColor())
                .codeBackgroundColor(theme.background());
    }*/

    override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
        builder.syntaxHighlight(
            Prism4jSyntaxHighlight.create(
                prism4j,
                theme,
                fallbackLanguage
            )
        )
    }

    override fun configureTheme(builder: MarkwonCategoryTheme) {
        super.configureTheme(builder)
    }

    companion object {
        @JvmOverloads
        fun create(
            prism4j: Prism4j,
            theme: Prism4jTheme,
            fallbackLanguage: String? = null
        ): SyntaxHighlightPlugin {
            return SyntaxHighlightPlugin(prism4j, theme, fallbackLanguage)
        }
    }
}